package com.b2b.config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2020-10-3
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {

//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2021000117688772";

	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCXUgdeHNrXDXu0EtEug//McKWl/LJvDtZxP03AxqRhr2RbfJf3YGpCF4/fauKmecQIftk8h/jWcvSDin0+R8DAmNh/CeyrpQ95B3hl1kCsYIASuqDHc3L8JchKCGlsgvAdApPje6s5tu89SE0GyCLD30pGWAvKyWh2igjJUZHUaRAGr0fTnH7RExkOBsFwEP7wrF4uRhG5yA+LofnbYuQBXMs1qSnq7O/x+JqnrstmmaVTMIkY3UnVkWFy+J/8nGjfnxRaCjE9ZbWTT5ed4Ob3JA/5KXnNVb1YhFS84zWX3Elu8HTld7bbOrBpg57apoONvItDPSxmaU4pO3+8r26vAgMBAAECggEANhIPo+d3o0SkIVJgANkV/H18E3XaZKjOo6TVKb9RWb6Mg8xfmPuQvJEizdipqIb2L3r0MRb9KdPl32MLIcgN7kQviCWJtkPC5aJvuSP39CB/YzHg5aQxQDxX92xOD4IyPot/QNgd9P+TOTiunW/CTG9rYPtxK0MQ2tq0DQviqh1awGp8xKWw+MoECsEXdCe3egHeY+Xl1eT8/1MOpX6byIGanKNrU41jZv6TscrfSpYA8tJRAIofE5e/B2e6MsK+w7jo/1rDkgmQoJw209VDsfH/9gWL7utgPNyNZ+cmrIW1cq7xsYHVMqydMk0+5g8jwqsedasaLxXbzxJZR1v7AQKBgQDgvz6qZwWQrAts7UzHcckZNXiigwOHiFBrsba14gHzCBi4H714OVYIHd93RIDMMhAiAFismyS2+KefMWffIn9tfAwpBVQnRZsr3ZuWeFSbnYW1elSue+k7IqjgholypaLrgBtPdbuaCvAPBIbXGfWzk+UqjaHtemLrCT/dAXVYQQKBgQCsXN/djzHLM5SNRR3plP7EltQN0BMvs88E0AOkx6Ac6D2tnUcEuIMsm2Jqz79r1EIGO73S4jcfu5WIohWqgIzGfvjyzipi8ZdkUjydKg0ILA7uB775k4DDctNy8HJlOIhylvV01wBc3kOt4/Gurs5O6uu4atDsH2z2CaL/Qs+K7wKBgF17rxk6GPqAVZBNdG5RShCOSUtvq3womyrwlMs64wywBXgw26KyVrKxmk4F1H0bJdK+yiOhtLfW3gI9jrMlqlNkEbrOWJ6tOUoZt6nzC15fO0qtQ6QALpdGZ3BdBbcGZqoGc1Wt5wbAHfJhM6UtSyITFnOIzh31lkelZUcMYD8BAoGBAImsSVfUN6aiFYbdbS4Ux4ZJHynFSH3ytmmWqUJl/Rr52cIh/QblRklL98lvFOvRB8eo0k9uRy9+issvA/VDZq5p3vk5+Zs8c3s7QJUccHpVjrtLzpvU2KXEwuZs7kKxbDNzJq3jybNkCVUM3A92Ku3YMN4F28iutT60pdAUEmhbAoGBAKnLd7Z/SxyLJ+7b+elEnGnwzmV6wLcc0r75nLw5S1E/ox/MTjMW/pjeX6pe7fH2LVL1RcUqFJQVh9XcsC+hkH/1y3BWxwGvEFdGLxQLPnKpEUFcSRcg2tbdmAv7kSMAGquNdWCQ1NRfCMdbvt6ObOki3c+HSC5t6uEXswIRIFw5";
    // 应用私钥 (private_key)
    public static String private_key  = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDDC0AYQ/cl4aV3p+3Ke4N7YYYZZyUe85V6s+ggs49+lnr6CIT/Z9d6pfSlE8MdzPe/PBWTCJqDQLySW06f7y02tyNq6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3l41EqhwbP+sMPeHmcAP/iHDafoZJQ58tJeJyigsPTytQhAoGAQNJmcuiXjibP7irKMQfzVJUIUd0xsRwvTu5yZJV6wI5kKrby5y83iuvWR7Bwvdsu4h6BsrfhHW0vO/G82fF9XbTwJ5sVfJF7xznWm0KonH5mXQxSyoL7nT8gLoUh5s68Z49ZRkBi8MENyinKiuejnEc7X7924Ut1bXLCy4faDAECgYEAgIQqwXuJSw8gxQrbf+0NaZ/FnJ/cYgPC0i3JbzxvB2uk4h0it4D1LC+dxypryfxD8dFvfUIpR3+wOUQMSyK3WKWRM+4CONciAdk+Wg4s/ucCXYc1QV+qXbjvXsDNjoZtj+65QgHvSisYvFIIVPx3OFVq45qJ9Nf+AvlMYa7abdY=";
    // 应用公钥证书路径,app_cert_path 文件绝对路径
    public static String app_cert_path = "C:\\Users\\Asus\\Desktop\\cer\\appCertPublicKey_2021000117686769.crt";
//    public static String app_cert_path = "https://sandbox.alipaydev.com/user/securityCertDownLoad.json?appId=2021000117686769&signType=RSA2&certSource=PARTNER&serialNumber=f10f03c7ed57a75d5611061aab0f64a6";
    // 支付宝公钥证书文件路径（alipay_cert_path 文件绝对路径）
    public static String alipay_cert_path = "C:\\Users\\Asus\\Desktop\\cer\\alipayCertPublicKey_RSA2.crt";
//    public static String alipay_cert_path = "https://sandbox.alipaydev.com/user/securityCertDownLoad.json?appId=2021000117686769&signType=RSA2&certSource=ALIPAY_PID&serialNumber=d79b3c6c5fc2e7e065be898c2ac7fd53";
    // 支付宝 CA 根证书文件路径（alipay_root_cert_path 文件绝对路径）
//    public static String alipay_root_cert_path = "https://sandbox.alipaydev.com/user/securityCertDownLoad.json?appId=2021000117686769&signType=RSA2&certSource=ALIPAY_ROOT&serialNumber=";
    public static String alipay_root_cert_path = "C:\\Users\\Asus\\Desktop\\cer\\alipayRootCert.crt";
    // 请求网关 (gateway)
    public static String gateway = "https://openapi.alipaydev.com/gateway.do";
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAip8QTNQoE+U1GNIEvL8cARHtMN5zGaUsDiHHH6g31Xufyiv6Us9jUkL1t7UIXeK2IfXuzUu+nBE58c+wQFXzY0XKBbyYoF4a4dybQCLov8pyV/+pvFKcQ4Gzc+KdnhED5ukmLZa2a/G85THdWtQBqfLnwqFuRiAQXtTQYLg7MuI6my3DcnkAYluCV+LHG0ALdM73ODjqhQArrWGfsX/9ZWtpWNICBaIrByV1wGdLiiYcF+RvPFcTEjPP47RPBBa+5TBvy34tO/uuXTv8VYTd8804E+C7UIUObWJTifwffem+hvEZzt2+G+YTMNTPTgmKZDqJrlnMe88iH9T5UknWyQIDAQAB";
    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://localhost:1982/buyer/order";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "http://localhost:8080/payment/alipayReturnNotice";

    public static String return_url2 = "http://localhost:8080/payment/alipayReturnNotice2";

	// 签名方式
	public static String sign_type = "RSA2";

	// 字符编码格式
	public static String charset = "utf-8";

    public final static String FORMAT = "JSON";// 返回格式

	// 支付宝网关
	public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

	// 支付宝网关
	public static String log_path = "D:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

